# coding=utf-8
import types


class Person():
    def __init__(self, name, age):
        self.name = name
        self.age = age


p1 = Person("jhon", 20)
p2 = Person("parker", 20)

# 动态给对象添加属性
p1.score = 100
print(p1.score)
# 只给p1添加了属性，p2没有
# print(p2.score)


# 动态给对象添加方法
def run(self):
    print(f"{self.name}, running")


# types.MethodType(run,p1)则是告诉解释器，self指的就是p1
p1.run = types.MethodType(run, p1)
p1.run()
